package com.ai.entity.security.page;

import cn.hutool.core.collection.CollectionUtil;
import com.ai.common.constant.enumP.RoleTypeEnum;
import com.ai.entity.security.SysRole;
import com.ai.entity.comm.page.SysBasePage;
import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;


@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysRolePage extends SysBasePage<SysRole> {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty("角色名")
    private String roleName;

    @ApiModelProperty("角色说明")
    private String roleDescription;


    @ApiModelProperty("组织id")
    private List<String> regionBaseIdList;

    public QueryWrapper<SysRole> getQuery(QueryWrapper<SysRole> queryWrapper) {
        return super.getQuery(queryWrapper)
                .like(!StringUtils.isEmpty(roleName),"role_name",roleName)
                .like(!(StringUtils.isEmpty(roleDescription)),"role_description",roleDescription)
                .in(CollectionUtil.isNotEmpty(regionBaseIdList),"region_base_id",regionBaseIdList)
                .eq("role_type", RoleTypeEnum.ROLE_SYS.getRoleType());
    }


}
